package io.renren.modules.teacher.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import io.renren.common.utils.ShiroUtils;
import io.renren.modules.teacher.service.TeacherStudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author wks
 * @date 2022/2/10 15:57
 */
@RestController
@RequestMapping("/teacher/student")
public class TeacherStudentController {
    @Autowired
    TeacherStudentService teacherStudentService;

    @GetMapping("/list")
    public R list(@RequestParam Map<String, Object> params) {

        params.put("classId", ShiroUtils.getUserEntity().getClassId());
        Page<Map<String, Object>> page = new Page<>( Long.valueOf(String.valueOf(params.get("page"))),  Long.valueOf(String.valueOf(params.get("limit"))));
        IPage<Map<String, Object>> mapIPage = teacherStudentService.selectStudentList(page, params);
        PageUtils newPage = new PageUtils(mapIPage);

        return R.ok().put("page", newPage);
    }
}
